#include <iostream>
#include <vector>
using namespace std;

int main(int argc, char const *argv[])
{
    cout << "101 pointer" << endl;
    // 指针类型p1变量存在栈中
    // new int 堆中
    int* p1 = new int;
    int* p3 = new int[10]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    int arr1[3] = {1, 2, 3};
    int arr2[2][3] = {{1, 2, 3}, {4, 5, 6}};
    cout << "sizeof(arr1[3]) = " << sizeof(arr1) << endl;
    cout << "sizeof(arr2[2][3]) = " << sizeof(arr2) << endl;

    // *间接访问
    *p1 = 101;
    int i = 10;
    cout << "i = " << i << endl;
    int* p2 = &i;
    *p2 = 102;
    cout << "i = " << i << endl;
    cout << "p1 = " << p1 << endl;
    cout << "sizeof(p1) = " << sizeof(p1) << endl;
    cout << "sizeof(*p1) = " << sizeof(*p1) << endl;
    delete p1;
    p1 = nullptr; // nullptr c++11
    delete [] p3;
    p3 = nullptr;

    return 0;
}
